Skip to main content

Icons

Icons to replace default ones in the library should be in vector format packed in XML. New icons should have the correct naming format and be stored in the res/drawable directory.

Access to icons is done by referring to resources and creating a VectorResource object (which can only be initialized in a Composable function).

Changing DxCharts library icons is done by implementing interfaces in the com.devexperts.dxcharts.lib.ui.theme.icons package:

  1. com.devexperts.dxcharts.lib.ui.theme.icons.CommonIcons
  2. com.devexperts.dxcharts.lib.ui.theme.icons.StudiesIcons
  3. com.devexperts.dxcharts.lib.ui.theme.icons.ToolbarIcons
  4. com.devexperts.dxcharts.lib.ui.theme.icons.TopBarIcons

You can find all icons and their names and default implementation here

val commonIcons = object : CommonIcons {
override val Erase: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon1)
override val Bin: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon2)
/*
Other values overriding
*/
}
val studiesIcons = object : StudiesIcons {
override val ListItem: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon3)
override val LineType: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon4)
/*
Other values overriding
*/
}
val toolbarIcons = object : ToolbarIcons {
override val Brush: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon5)
override val ChartTypes: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon6)
/*
Other values overriding
*/
}
val topBarIcons = object : TopBarIcons {
override val ArrowBack: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon7)
override val ArrowForward: ImageVector
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon8)
}
DxChartsTheme(
commonIcons = commonIcons,
studiesIcons = studiesIcons,
toolbarIcons = toolbarIcons,
topBarIcons = topBarIcons
) {
/* content */
}

Initialization can also be done using default icons:

  1. com.devexperts.dxcharts.lib.ui.theme.icons.DefaultCommonIcons
  2. com.devexperts.dxcharts.lib.ui.theme.icons.DefaultStudiesIcons
  3. com.devexperts.dxcharts.lib.ui.theme.icons.DefaultToolbarIcons
  4. com.devexperts.dxcharts.lib.ui.theme.icons.DefaultTopBarIcons
val topBarIcons = object : TopBarIcons {
override val ArrowBack: ImageVector // Initialization with new icon resourse
@Composable get() = ImageVector.vectorResource(id = R.drawable.ic_icon7)
override val ArrowForward: ImageVector // Initialization with default icon
@Composable get() = DefaultTopBarIcons.ArrowForward
}
DxChartsTheme(
topBarIcons = topBarIcons
) {
/* content */
}